using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlTypes;
using System.Data.SqlClient;
using System.Text;
using ECommerce.DAL;


namespace Entity
{
	/// <summary>
	/// This object represents the Private Fields of TblTax.
	/// </summary>
	
	[System.ComponentModel.DataObject]
    public partial class TblTax : DatabaseUtility
    {
		#region TblTax Private Fields


		Int32 _taxId;
		String _sTAX_CODE = String.Empty;
		String _sTAX_DESC = String.Empty;
		String _tAX_FRT = String.Empty;
		DateTime _vERTEX_UPDT_DATE;
		String _vERTEX_UPDT_NUM = String.Empty;
		String _vERTEX_EFF_DATE = String.Empty;
		String _sTAX_P_A = String.Empty;
		String _aCCR_S_A = String.Empty;
		String _cITY_STS = String.Empty;
		String _aR5_UNUSED_1 = String.Empty;
		String _zIP_STS = String.Empty;
		String _sTATE_STS = String.Empty;
		String _cOUNTY_STS = String.Empty;
		String _aR5_UNUSED_2 = String.Empty;
		String _cOUNTY_CODE_STS = String.Empty;
		String _tF_STATE = String.Empty;
		String _tF_COUNTY = String.Empty;
		String _tF_CITY = String.Empty;
		String _sTATE_DESC = String.Empty;
		String _nO_OVRDE_T_C = String.Empty;
		String _tOTAL_TAX = String.Empty;
		String _aR5_UNUSED_3 = String.Empty;
		Double _sTAX_RATE;
		Double _mAX_STAX;
		Double _cOUNTY_TAX_IF_OTHER;
		Double _sTATE_TAX_IF_OTHER;
		Double _sT_STAX_RATE;
		Double _cNTY_STAX_RATE;
		Double _mAX_OTHER;
		Double _tAX_RATE_TOTAL;
		String _uSE_CANADA = String.Empty;
		String _tAX_TAX = String.Empty;
		String _tAX_SPL_CHG = String.Empty;
		
		#endregion
		#region TblTax Constractor
		/// <summary>
        /// Creates an empty object of TblTax. 
        /// This is mainly used to create a new instance of TblTax to add a new TblTax.
        /// </summary>
		public TblTax(){}
		
				
		/// <summary>
        /// Used to retrieve employee information from database, 
        /// which is also used by Update method to save information of an existing TblTax.
        /// </summary>
		public TblTax
		(
			Int32 taxId,
			String sTAX_CODE,
			String sTAX_DESC,
			String tAX_FRT,
			DateTime vERTEX_UPDT_DATE,
			String vERTEX_UPDT_NUM,
			String vERTEX_EFF_DATE,
			String sTAX_P_A,
			String aCCR_S_A,
			String cITY_STS,
			String aR5_UNUSED_1,
			String zIP_STS,
			String sTATE_STS,
			String cOUNTY_STS,
			String aR5_UNUSED_2,
			String cOUNTY_CODE_STS,
			String tF_STATE,
			String tF_COUNTY,
			String tF_CITY,
			String sTATE_DESC,
			String nO_OVRDE_T_C,
			String tOTAL_TAX,
			String aR5_UNUSED_3,
			Double sTAX_RATE,
			Double mAX_STAX,
			Double cOUNTY_TAX_IF_OTHER,
			Double sTATE_TAX_IF_OTHER,
			Double sT_STAX_RATE,
			Double cNTY_STAX_RATE,
			Double mAX_OTHER,
			Double tAX_RATE_TOTAL,
			String uSE_CANADA,
			String tAX_TAX,
			String tAX_SPL_CHG
		)
		{
			_taxId = taxId;	
			_sTAX_CODE = sTAX_CODE;	
			_sTAX_DESC = sTAX_DESC;	
			_tAX_FRT = tAX_FRT;	
			_vERTEX_UPDT_DATE = vERTEX_UPDT_DATE;	
			_vERTEX_UPDT_NUM = vERTEX_UPDT_NUM;	
			_vERTEX_EFF_DATE = vERTEX_EFF_DATE;	
			_sTAX_P_A = sTAX_P_A;	
			_aCCR_S_A = aCCR_S_A;	
			_cITY_STS = cITY_STS;	
			_aR5_UNUSED_1 = aR5_UNUSED_1;	
			_zIP_STS = zIP_STS;	
			_sTATE_STS = sTATE_STS;	
			_cOUNTY_STS = cOUNTY_STS;	
			_aR5_UNUSED_2 = aR5_UNUSED_2;	
			_cOUNTY_CODE_STS = cOUNTY_CODE_STS;	
			_tF_STATE = tF_STATE;	
			_tF_COUNTY = tF_COUNTY;	
			_tF_CITY = tF_CITY;	
			_sTATE_DESC = sTATE_DESC;	
			_nO_OVRDE_T_C = nO_OVRDE_T_C;	
			_tOTAL_TAX = tOTAL_TAX;	
			_aR5_UNUSED_3 = aR5_UNUSED_3;	
			_sTAX_RATE = sTAX_RATE;	
			_mAX_STAX = mAX_STAX;	
			_cOUNTY_TAX_IF_OTHER = cOUNTY_TAX_IF_OTHER;	
			_sTATE_TAX_IF_OTHER = sTATE_TAX_IF_OTHER;	
			_sT_STAX_RATE = sT_STAX_RATE;	
			_cNTY_STAX_RATE = cNTY_STAX_RATE;	
			_mAX_OTHER = mAX_OTHER;	
			_tAX_RATE_TOTAL = tAX_RATE_TOTAL;	
			_uSE_CANADA = uSE_CANADA;	
			_tAX_TAX = tAX_TAX;	
			_tAX_SPL_CHG = tAX_SPL_CHG;	
		}
		
		#endregion
		#region TblTax Properties
		
		 /***********************************************************************************************
                                    -- PROPERTIES --        
         Contains all the properties representing the data fields of the current entity.
         ***********************************************************************************************/

        /// <summary>
        /// This is the Primary key value of the TaxId, which can't be assigned from the application,
        /// to ensure the data consistancy, by not letting the user to change the PK_TblTax to update the data of an another TblTax instance.
        /// For view or updation purpose, every TblTax will be retrieved thru the proper 'Get' method.
        /// </summary>
		
		public Int32 TaxId
		{
			get {return _taxId;}	
		}
		
				
		public String STAX_CODE
		{
			get {return _sTAX_CODE;}
			set {_sTAX_CODE = value;}
		}

		public String STAX_DESC
		{
			get {return _sTAX_DESC;}
			set {_sTAX_DESC = value;}
		}

		public String TAX_FRT
		{
			get {return _tAX_FRT;}
			set {_tAX_FRT = value;}
		}

		public DateTime VERTEX_UPDT_DATE
		{
			get {return _vERTEX_UPDT_DATE;}
			set {_vERTEX_UPDT_DATE = value;}
		}

		public String VERTEX_UPDT_NUM
		{
			get {return _vERTEX_UPDT_NUM;}
			set {_vERTEX_UPDT_NUM = value;}
		}

		public String VERTEX_EFF_DATE
		{
			get {return _vERTEX_EFF_DATE;}
			set {_vERTEX_EFF_DATE = value;}
		}

		public String STAX_P_A
		{
			get {return _sTAX_P_A;}
			set {_sTAX_P_A = value;}
		}

		public String ACCR_S_A
		{
			get {return _aCCR_S_A;}
			set {_aCCR_S_A = value;}
		}

		public String CITY_STS
		{
			get {return _cITY_STS;}
			set {_cITY_STS = value;}
		}

		public String AR5_UNUSED_1
		{
			get {return _aR5_UNUSED_1;}
			set {_aR5_UNUSED_1 = value;}
		}

		public String ZIP_STS
		{
			get {return _zIP_STS;}
			set {_zIP_STS = value;}
		}

		public String STATE_STS
		{
			get {return _sTATE_STS;}
			set {_sTATE_STS = value;}
		}

		public String COUNTY_STS
		{
			get {return _cOUNTY_STS;}
			set {_cOUNTY_STS = value;}
		}

		public String AR5_UNUSED_2
		{
			get {return _aR5_UNUSED_2;}
			set {_aR5_UNUSED_2 = value;}
		}

		public String COUNTY_CODE_STS
		{
			get {return _cOUNTY_CODE_STS;}
			set {_cOUNTY_CODE_STS = value;}
		}

		public String TF_STATE
		{
			get {return _tF_STATE;}
			set {_tF_STATE = value;}
		}

		public String TF_COUNTY
		{
			get {return _tF_COUNTY;}
			set {_tF_COUNTY = value;}
		}

		public String TF_CITY
		{
			get {return _tF_CITY;}
			set {_tF_CITY = value;}
		}

		public String STATE_DESC
		{
			get {return _sTATE_DESC;}
			set {_sTATE_DESC = value;}
		}

		public String NO_OVRDE_T_C
		{
			get {return _nO_OVRDE_T_C;}
			set {_nO_OVRDE_T_C = value;}
		}

		public String TOTAL_TAX
		{
			get {return _tOTAL_TAX;}
			set {_tOTAL_TAX = value;}
		}

		public String AR5_UNUSED_3
		{
			get {return _aR5_UNUSED_3;}
			set {_aR5_UNUSED_3 = value;}
		}

		public Double STAX_RATE
		{
			get {return _sTAX_RATE;}
			set {_sTAX_RATE = value;}
		}

		public Double MAX_STAX
		{
			get {return _mAX_STAX;}
			set {_mAX_STAX = value;}
		}

		public Double COUNTY_TAX_IF_OTHER
		{
			get {return _cOUNTY_TAX_IF_OTHER;}
			set {_cOUNTY_TAX_IF_OTHER = value;}
		}

		public Double STATE_TAX_IF_OTHER
		{
			get {return _sTATE_TAX_IF_OTHER;}
			set {_sTATE_TAX_IF_OTHER = value;}
		}

		public Double ST_STAX_RATE
		{
			get {return _sT_STAX_RATE;}
			set {_sT_STAX_RATE = value;}
		}

		public Double CNTY_STAX_RATE
		{
			get {return _cNTY_STAX_RATE;}
			set {_cNTY_STAX_RATE = value;}
		}

		public Double MAX_OTHER
		{
			get {return _mAX_OTHER;}
			set {_mAX_OTHER = value;}
		}

		public Double TAX_RATE_TOTAL
		{
			get {return _tAX_RATE_TOTAL;}
			set {_tAX_RATE_TOTAL = value;}
		}

		public String USE_CANADA
		{
			get {return _uSE_CANADA;}
			set {_uSE_CANADA = value;}
		}

		public String TAX_TAX
		{
			get {return _tAX_TAX;}
			set {_tAX_TAX = value;}
		}

		public String TAX_SPL_CHG
		{
			get {return _tAX_SPL_CHG;}
			set {_tAX_SPL_CHG = value;}
		}
		

		#endregion
		#region TblTax Static Methods
		/************************************************************************************
                                    -- CREATE METHOD (STATIC) --
        *************************************************************************************/
		/************************* Architecure note:**********************************
        Note 1:
        This method is specially useful for the case, where we need to use Object Data Source controls.
        For ObjectDataSource/SqlDataSource controls, the insert/update metnod requires paramters methods, rather property based methods.
        However, there is still a way to pass property based objects as method parameter for data source controls, 
        but in that case we could not use Sql type, as view controls or asp parameter control can only contain few of primitive type.
        The main reason to remain the Sql Type in our object architecture is it is faster and contains better way for null value support.
        
        Note 2: 
        Non-primary key: it should be primitive type, as the asp paramter control (included in data source control) supports only primitive types.
        /*****************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
        public static  Int32 CreateNewTblTax
		(
			String sTAX_CODE,
			String sTAX_DESC,
			String tAX_FRT,
			DateTime vERTEX_UPDT_DATE,
			String vERTEX_UPDT_NUM,
			String vERTEX_EFF_DATE,
			String sTAX_P_A,
			String aCCR_S_A,
			String cITY_STS,
			String aR5_UNUSED_1,
			String zIP_STS,
			String sTATE_STS,
			String cOUNTY_STS,
			String aR5_UNUSED_2,
			String cOUNTY_CODE_STS,
			String tF_STATE,
			String tF_COUNTY,
			String tF_CITY,
			String sTATE_DESC,
			String nO_OVRDE_T_C,
			String tOTAL_TAX,
			String aR5_UNUSED_3,
			Double sTAX_RATE,
			Double mAX_STAX,
			Double cOUNTY_TAX_IF_OTHER,
			Double sTATE_TAX_IF_OTHER,
			Double sT_STAX_RATE,
			Double cNTY_STAX_RATE,
			Double mAX_OTHER,
			Double tAX_RATE_TOTAL,
			String uSE_CANADA,
			String tAX_TAX,
			String tAX_SPL_CHG
		)
		{
			//creating an empty TblTax object
            TblTax tblTax = new TblTax();
				tblTax.STAX_CODE = sTAX_CODE;
				tblTax.STAX_DESC = sTAX_DESC;
				tblTax.TAX_FRT = tAX_FRT;
				tblTax.VERTEX_UPDT_DATE = vERTEX_UPDT_DATE;
				tblTax.VERTEX_UPDT_NUM = vERTEX_UPDT_NUM;
				tblTax.VERTEX_EFF_DATE = vERTEX_EFF_DATE;
				tblTax.STAX_P_A = sTAX_P_A;
				tblTax.ACCR_S_A = aCCR_S_A;
				tblTax.CITY_STS = cITY_STS;
				tblTax.AR5_UNUSED_1 = aR5_UNUSED_1;
				tblTax.ZIP_STS = zIP_STS;
				tblTax.STATE_STS = sTATE_STS;
				tblTax.COUNTY_STS = cOUNTY_STS;
				tblTax.AR5_UNUSED_2 = aR5_UNUSED_2;
				tblTax.COUNTY_CODE_STS = cOUNTY_CODE_STS;
				tblTax.TF_STATE = tF_STATE;
				tblTax.TF_COUNTY = tF_COUNTY;
				tblTax.TF_CITY = tF_CITY;
				tblTax.STATE_DESC = sTATE_DESC;
				tblTax.NO_OVRDE_T_C = nO_OVRDE_T_C;
				tblTax.TOTAL_TAX = tOTAL_TAX;
				tblTax.AR5_UNUSED_3 = aR5_UNUSED_3;
				tblTax.STAX_RATE = sTAX_RATE;
				tblTax.MAX_STAX = mAX_STAX;
				tblTax.COUNTY_TAX_IF_OTHER = cOUNTY_TAX_IF_OTHER;
				tblTax.STATE_TAX_IF_OTHER = sTATE_TAX_IF_OTHER;
				tblTax.ST_STAX_RATE = sT_STAX_RATE;
				tblTax.CNTY_STAX_RATE = cNTY_STAX_RATE;
				tblTax.MAX_OTHER = mAX_OTHER;
				tblTax.TAX_RATE_TOTAL = tAX_RATE_TOTAL;
				tblTax.USE_CANADA = uSE_CANADA;
				tblTax.TAX_TAX = tAX_TAX;
				tblTax.TAX_SPL_CHG = tAX_SPL_CHG;
			
			return TblTax.CreateNewTblTax(tblTax);
		}
	
		/************************************************************************************
                 -- UPDATE METHODS (STATIC) --
        *************************************************************************************/

        /************************* Architecure note:**********************************
        Note 1:
        This method is specially useful for the case, where we need to use Object Data Source controls.
        For ObjectDataSource/SqlDataSource controls, the insert/update metnod requires paramters methods, rather property based methods.
        However, there is still a way to pass property based objects as method parameter for data source controls, 
        but in that case we could not use Sql type, as view controls or asp parameter control can only contain few of primitive type.
        The main reason to remain the Sql Type in our object architecture is it is faster and contains better way for null value support.
        
        Note 2: 
        There the two types of paramaters will be passed here.
         * a. Primary key paramater: it should be Sql type, as we will bind the primary key property for the view controls (form view, details view etc) as datakey.
         * b. Non-primary key: it should be primitive type, as the asp paramter control (included in data source control) supports only primitive types.
        /*****************************************************************************/
		
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static  bool UpdateTblTax
		(
			Int32 taxId,
			String sTAX_CODE,
			String sTAX_DESC,
			String tAX_FRT,
			DateTime vERTEX_UPDT_DATE,
			String vERTEX_UPDT_NUM,
			String vERTEX_EFF_DATE,
			String sTAX_P_A,
			String aCCR_S_A,
			String cITY_STS,
			String aR5_UNUSED_1,
			String zIP_STS,
			String sTATE_STS,
			String cOUNTY_STS,
			String aR5_UNUSED_2,
			String cOUNTY_CODE_STS,
			String tF_STATE,
			String tF_COUNTY,
			String tF_CITY,
			String sTATE_DESC,
			String nO_OVRDE_T_C,
			String tOTAL_TAX,
			String aR5_UNUSED_3,
			Double sTAX_RATE,
			Double mAX_STAX,
			Double cOUNTY_TAX_IF_OTHER,
			Double sTATE_TAX_IF_OTHER,
			Double sT_STAX_RATE,
			Double cNTY_STAX_RATE,
			Double mAX_OTHER,
			Double tAX_RATE_TOTAL,
			String uSE_CANADA,
			String tAX_TAX,
			String tAX_SPL_CHG
		)
		{
			 TblTax tblTax =  TblTax.GetTblTaxByTaxId(taxId);
			
				tblTax.STAX_CODE = sTAX_CODE;
				tblTax.STAX_DESC = sTAX_DESC;
				tblTax.TAX_FRT = tAX_FRT;
				tblTax.VERTEX_UPDT_DATE = vERTEX_UPDT_DATE;
				tblTax.VERTEX_UPDT_NUM = vERTEX_UPDT_NUM;
				tblTax.VERTEX_EFF_DATE = vERTEX_EFF_DATE;
				tblTax.STAX_P_A = sTAX_P_A;
				tblTax.ACCR_S_A = aCCR_S_A;
				tblTax.CITY_STS = cITY_STS;
				tblTax.AR5_UNUSED_1 = aR5_UNUSED_1;
				tblTax.ZIP_STS = zIP_STS;
				tblTax.STATE_STS = sTATE_STS;
				tblTax.COUNTY_STS = cOUNTY_STS;
				tblTax.AR5_UNUSED_2 = aR5_UNUSED_2;
				tblTax.COUNTY_CODE_STS = cOUNTY_CODE_STS;
				tblTax.TF_STATE = tF_STATE;
				tblTax.TF_COUNTY = tF_COUNTY;
				tblTax.TF_CITY = tF_CITY;
				tblTax.STATE_DESC = sTATE_DESC;
				tblTax.NO_OVRDE_T_C = nO_OVRDE_T_C;
				tblTax.TOTAL_TAX = tOTAL_TAX;
				tblTax.AR5_UNUSED_3 = aR5_UNUSED_3;
				tblTax.STAX_RATE = sTAX_RATE;
				tblTax.MAX_STAX = mAX_STAX;
				tblTax.COUNTY_TAX_IF_OTHER = cOUNTY_TAX_IF_OTHER;
				tblTax.STATE_TAX_IF_OTHER = sTATE_TAX_IF_OTHER;
				tblTax.ST_STAX_RATE = sT_STAX_RATE;
				tblTax.CNTY_STAX_RATE = cNTY_STAX_RATE;
				tblTax.MAX_OTHER = mAX_OTHER;
				tblTax.TAX_RATE_TOTAL = tAX_RATE_TOTAL;
				tblTax.USE_CANADA = uSE_CANADA;
				tblTax.TAX_TAX = tAX_TAX;
				tblTax.TAX_SPL_CHG = tAX_SPL_CHG;
			
			return TblTax.UpdateTblTax(tblTax);
		}

		/************************************************************************************
                         -- DELETE METHODS --
        *************************************************************************************/
        /************************* Architecure note:**********************************
        We have used the employeeId parameter as SqlInt32, to bind the delete method with object data source and view control directly.
        ****************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static  bool DeleteTblTax
		(
			Int32 taxId
		)
		{
			//Validate Input
			if(taxId <= GetTaxIdMinValue)
				throw (new ArgumentOutOfRangeException("taxId"));
				
			// Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
			AddParameterToSqlCmd(sqlCmd, "@TaxId",SqlDbType.Int, 0, ParameterDirection.Input, taxId);
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLTAX_DELETETBLTAX);
			ExecuteScalarCmd(sqlCmd);
			int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
			return (returnValue == 0 ? false : true);
			
		}
		
		/// <summary>
        /// Deletes a set of employees from the database.
        /// </summary>
		public static bool DeleteTblTaxList( System.Collections.Generic.List<Int32>  taxIdListToDelete)
		{
			//Validate Input
			foreach (Int32 taxId in taxIdListToDelete)
			    if(taxId <= GetTaxIdMinValue)
					throw (new ArgumentOutOfRangeException("taxId"));
			
			//performing deletion operation //

            string xmlString = FormatXMLForIdArray(taxIdListToDelete);
			
			// Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            AddParameterToSqlCmd(sqlCmd, "@TaxIdList", SqlDbType.Xml, xmlString.ToString().Length, ParameterDirection.Input, xmlString.ToString());
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLTAX_DELETETBLTAXLIST);
			ExecuteScalarCmd(sqlCmd);
			int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
			return (returnValue == taxIdListToDelete.Count ? true : false);
		}
		
		/************************************************************************************
                                 -- GET BY PRIMARY METHODS --
        *************************************************************************************/
        /************************* Architecure note:**********************************
        Retrives an Employee from database, based on it's primary key.
        To view or update an employee, everytime we must have to use this type of 'get' method, 
        since we don't have direct access to the Primary key value for assigning value.
        We have used the employeeId parameter as SqlInt32, to bind the delete method with object data source and view control directly.
        /*****************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
		public static TblTax GetTblTaxByTaxId(Int32 taxId)
		{
			if(taxId <= GetTaxIdMinValue)
					throw (new ArgumentOutOfRangeException("taxId"));
				
		 	// Execute SQL Command
			SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@TaxId",SqlDbType.Int, 0, ParameterDirection.Input, taxId);
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLTAX_GETTBLTAXBYTAXID);
			GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblTaxCollectionFromReader);
            CustomCollection<TblTax> objCollection = ((CustomCollection<TblTax>)ExecuteReaderCmd(sqlCmd, test));

            if (objCollection.Count > 0)
                return objCollection[0];
            else
                return null;
		}
		
		/************************************************************************************
                         -- GET BY FOREIGN KEY METHODS --
        *************************************************************************************/
		
		/************************************************************************************
                 -- GET ALL METHODS --
        *************************************************************************************/
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static CustomCollection<TblTax> GetAllTblTax()
		{
		
		 	// Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLTAX_GETALLTBLTAX);
            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblTaxCollectionFromReader);
            CustomCollection<TblTax> objCollection = ((CustomCollection<TblTax>)ExecuteReaderCmd(sqlCmd, test));

            return objCollection;
		}
		
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static CustomCollection<TblTax> GetAllTblTaxPaged(String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            //Validate Input
            if (orderBy == "")
                orderBy = "TaxId";

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startrow", SqlDbType.Int, 0, ParameterDirection.Input, startRowIndex);
            AddParameterToSqlCmd(sqlCmd, "@pagesize", SqlDbType.Int, 0, ParameterDirection.Input, maximumRows);

            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLTAX_GETALLTBLTAXPAGED);

            GenerateCollectionFromReader test = new GenerateCollectionFromReader(GenerateTblTaxCollectionFromReader);
            CustomCollection<TblTax> objCollection = ((CustomCollection<TblTax>)ExecuteReaderCmd(sqlCmd, test));
            return objCollection;
        }
		
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static int GetAllTblTaxPagedCount(String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();

            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLTAX_GETALLTBLTAXPAGEDCOUNT);
            ExecuteScalarCmd(sqlCmd);

            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }
		
		#endregion
		#region Employee Instance Methods
		/************************************************************************************
                                    -- SAVE (INSERT/UPDATE) METHODS (INSTANCE) --
        *************************************************************************************/
		/// <summary>
        /// Saves (inserts and updates) an Employee into database.
        /// The insertion occur if the EmployeeId conatins default value.
        /// Otherwises it updates the Employee into the database, based on the primary key value stored in EmployeeId.
        /// This technique ensures an Employee will not be updated without having a valid EmployeeId.
        /// </summary>
		public bool Save()
		{
			if(TaxId<= GetTaxIdMinValue)
			{
				Int32 TempId=CreateNewTblTax(this);
				if(TempId>0)
				{
					_taxId=TempId;
					return true;
				}
				else
				{
					// error occurs
					return false;
				}
			}
			else
			{	//This is a update Command
				return (UpdateTblTax(this));
			}
			
		}
		
		public static Int32 CreateNewTblTax(TblTax newTblTax)
		{
			// validate Parameters
			if (newTblTax == null)
				throw (new ArgumentNullException("newTblTax"));

			// Execute SQL Command
			SqlCommand sqlCmd = new SqlCommand();
			int length = 0;
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            
			AddParameterToSqlCmd(sqlCmd, "@STAX_CODE",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.STAX_CODE);
			AddParameterToSqlCmd(sqlCmd, "@STAX_DESC",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.STAX_DESC);
			AddParameterToSqlCmd(sqlCmd, "@TAX_FRT",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TAX_FRT);
			AddParameterToSqlCmd(sqlCmd, "@VERTEX_UPDT_DATE",SqlDbType.DateTime, 0, ParameterDirection.Input, newTblTax.VERTEX_UPDT_DATE);
			AddParameterToSqlCmd(sqlCmd, "@VERTEX_UPDT_NUM",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.VERTEX_UPDT_NUM);
			AddParameterToSqlCmd(sqlCmd, "@VERTEX_EFF_DATE",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.VERTEX_EFF_DATE);
			AddParameterToSqlCmd(sqlCmd, "@STAX_P_A",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.STAX_P_A);
			AddParameterToSqlCmd(sqlCmd, "@ACCR_S_A",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.ACCR_S_A);
			AddParameterToSqlCmd(sqlCmd, "@CITY_STS",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.CITY_STS);
			AddParameterToSqlCmd(sqlCmd, "@AR5_UNUSED_1",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.AR5_UNUSED_1);
			AddParameterToSqlCmd(sqlCmd, "@ZIP_STS",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.ZIP_STS);
			AddParameterToSqlCmd(sqlCmd, "@STATE_STS",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.STATE_STS);
			AddParameterToSqlCmd(sqlCmd, "@COUNTY_STS",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.COUNTY_STS);
			AddParameterToSqlCmd(sqlCmd, "@AR5_UNUSED_2",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.AR5_UNUSED_2);
			AddParameterToSqlCmd(sqlCmd, "@COUNTY_CODE_STS",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.COUNTY_CODE_STS);
			AddParameterToSqlCmd(sqlCmd, "@TF_STATE",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TF_STATE);
			AddParameterToSqlCmd(sqlCmd, "@TF_COUNTY",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TF_COUNTY);
			AddParameterToSqlCmd(sqlCmd, "@TF_CITY",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TF_CITY);
			AddParameterToSqlCmd(sqlCmd, "@STATE_DESC",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.STATE_DESC);
			AddParameterToSqlCmd(sqlCmd, "@NO_OVRDE_T_C",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.NO_OVRDE_T_C);
			AddParameterToSqlCmd(sqlCmd, "@TOTAL_TAX",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TOTAL_TAX);
			AddParameterToSqlCmd(sqlCmd, "@AR5_UNUSED_3",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.AR5_UNUSED_3);
			AddParameterToSqlCmd(sqlCmd, "@STAX_RATE",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.STAX_RATE);
			AddParameterToSqlCmd(sqlCmd, "@MAX_STAX",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.MAX_STAX);
			AddParameterToSqlCmd(sqlCmd, "@COUNTY_TAX_IF_OTHER",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.COUNTY_TAX_IF_OTHER);
			AddParameterToSqlCmd(sqlCmd, "@STATE_TAX_IF_OTHER",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.STATE_TAX_IF_OTHER);
			AddParameterToSqlCmd(sqlCmd, "@ST_STAX_RATE",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.ST_STAX_RATE);
			AddParameterToSqlCmd(sqlCmd, "@CNTY_STAX_RATE",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.CNTY_STAX_RATE);
			AddParameterToSqlCmd(sqlCmd, "@MAX_OTHER",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.MAX_OTHER);
			AddParameterToSqlCmd(sqlCmd, "@TAX_RATE_TOTAL",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.TAX_RATE_TOTAL);
			AddParameterToSqlCmd(sqlCmd, "@USE_CANADA",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.USE_CANADA);
			AddParameterToSqlCmd(sqlCmd, "@TAX_TAX",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TAX_TAX);
			AddParameterToSqlCmd(sqlCmd, "@TAX_SPL_CHG",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TAX_SPL_CHG);
			
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLTAX_CREATENEWTBLTAX);
			ExecuteScalarCmd(sqlCmd);
			return (Int32.Parse(sqlCmd.Parameters["@ReturnValue"].Value.ToString()));

		}
		/// <summary>
        /// Updates an TblTax instance to the database.
        /// </summary>
		public static bool UpdateTblTax(TblTax newTblTax)
		{
			// validate Parameters
			if (newTblTax == null)
				throw (new ArgumentNullException("newTblTax"));

			// Execute SQL Command
			SqlCommand sqlCmd = new SqlCommand();
			int length = 0;
			AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            
			AddParameterToSqlCmd(sqlCmd, "@TaxId",SqlDbType.Int, 0, ParameterDirection.Input, newTblTax.TaxId);
			AddParameterToSqlCmd(sqlCmd, "@STAX_CODE",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.STAX_CODE);
			AddParameterToSqlCmd(sqlCmd, "@STAX_DESC",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.STAX_DESC);
			AddParameterToSqlCmd(sqlCmd, "@TAX_FRT",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TAX_FRT);
			AddParameterToSqlCmd(sqlCmd, "@VERTEX_UPDT_DATE",SqlDbType.DateTime, 0, ParameterDirection.Input, newTblTax.VERTEX_UPDT_DATE);
			AddParameterToSqlCmd(sqlCmd, "@VERTEX_UPDT_NUM",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.VERTEX_UPDT_NUM);
			AddParameterToSqlCmd(sqlCmd, "@VERTEX_EFF_DATE",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.VERTEX_EFF_DATE);
			AddParameterToSqlCmd(sqlCmd, "@STAX_P_A",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.STAX_P_A);
			AddParameterToSqlCmd(sqlCmd, "@ACCR_S_A",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.ACCR_S_A);
			AddParameterToSqlCmd(sqlCmd, "@CITY_STS",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.CITY_STS);
			AddParameterToSqlCmd(sqlCmd, "@AR5_UNUSED_1",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.AR5_UNUSED_1);
			AddParameterToSqlCmd(sqlCmd, "@ZIP_STS",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.ZIP_STS);
			AddParameterToSqlCmd(sqlCmd, "@STATE_STS",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.STATE_STS);
			AddParameterToSqlCmd(sqlCmd, "@COUNTY_STS",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.COUNTY_STS);
			AddParameterToSqlCmd(sqlCmd, "@AR5_UNUSED_2",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.AR5_UNUSED_2);
			AddParameterToSqlCmd(sqlCmd, "@COUNTY_CODE_STS",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.COUNTY_CODE_STS);
			AddParameterToSqlCmd(sqlCmd, "@TF_STATE",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TF_STATE);
			AddParameterToSqlCmd(sqlCmd, "@TF_COUNTY",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TF_COUNTY);
			AddParameterToSqlCmd(sqlCmd, "@TF_CITY",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TF_CITY);
			AddParameterToSqlCmd(sqlCmd, "@STATE_DESC",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.STATE_DESC);
			AddParameterToSqlCmd(sqlCmd, "@NO_OVRDE_T_C",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.NO_OVRDE_T_C);
			AddParameterToSqlCmd(sqlCmd, "@TOTAL_TAX",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TOTAL_TAX);
			AddParameterToSqlCmd(sqlCmd, "@AR5_UNUSED_3",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.AR5_UNUSED_3);
			AddParameterToSqlCmd(sqlCmd, "@STAX_RATE",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.STAX_RATE);
			AddParameterToSqlCmd(sqlCmd, "@MAX_STAX",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.MAX_STAX);
			AddParameterToSqlCmd(sqlCmd, "@COUNTY_TAX_IF_OTHER",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.COUNTY_TAX_IF_OTHER);
			AddParameterToSqlCmd(sqlCmd, "@STATE_TAX_IF_OTHER",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.STATE_TAX_IF_OTHER);
			AddParameterToSqlCmd(sqlCmd, "@ST_STAX_RATE",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.ST_STAX_RATE);
			AddParameterToSqlCmd(sqlCmd, "@CNTY_STAX_RATE",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.CNTY_STAX_RATE);
			AddParameterToSqlCmd(sqlCmd, "@MAX_OTHER",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.MAX_OTHER);
			AddParameterToSqlCmd(sqlCmd, "@TAX_RATE_TOTAL",SqlDbType.Float, 0, ParameterDirection.Input, newTblTax.TAX_RATE_TOTAL);
			AddParameterToSqlCmd(sqlCmd, "@USE_CANADA",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.USE_CANADA);
			AddParameterToSqlCmd(sqlCmd, "@TAX_TAX",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TAX_TAX);
			AddParameterToSqlCmd(sqlCmd, "@TAX_SPL_CHG",SqlDbType.NVarChar, 255, ParameterDirection.Input, newTblTax.TAX_SPL_CHG);
			
			SetCommandType(sqlCmd,CommandType.StoredProcedure,SPR_TBLTAX_UPDATETBLTAX);
            ExecuteScalarCmd(sqlCmd);
			int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
			return (returnValue == 0 ? false : true);
		}
		#endregion
		
		#region TblTax Related Collections
		/// <summary>
        /// Creates and returns a strongly typed collection of Employee custom entity. 
        /// The colelction is created through iterating on the IdataReader object which contains Employee information, as a set of records, similar to tabular format.
        /// </summary>
		public static CollectionBase  GenerateTblTaxCollectionFromReader(IDataReader returnData) 
		{
			
			//creating the instance of Employee collection
			CustomCollection<TblTax> colTblTax = new CustomCollection<TblTax>();
			
			/************************* Architecure note:**********************************
             * Below code includes the null value functionality to retieve the data which has nill value in database end.
             * Design consideration:
             * Besides general data fields, special care should be taken for primary keys, to assign '0'/defaultvalue, rather passing 'Null' value in constructor parameter.
             * Although we are considering sqldb tyoe data for the current data container, but while retireving data from database end, through datareader object, we need to cast data reader objects using .net primitive data type, 
             * rather using sqldb type to cast, since data reader objects don't support sql db type to be casted.
             *****************************************************************************/

            //Iterating thriugh the data reader, to generate Employee collection.

			//getting the Employee collection by iterating thru the data reader
			while (returnData.Read()) 
			{
				//passing the TblTax constructor parameters from the current instance of data reader fields.
				TblTax newTblTax = new TblTax
				(
					returnData["TaxId"]== System.DBNull.Value ? GetTaxIdMinValue : (Int32 ) returnData["TaxId"],
					returnData["STAX_CODE"]== System.DBNull.Value ? string.Empty: (String ) returnData["STAX_CODE"],
					returnData["STAX_DESC"]== System.DBNull.Value ? string.Empty: (String ) returnData["STAX_DESC"],
					returnData["TAX_FRT"]== System.DBNull.Value ? string.Empty: (String ) returnData["TAX_FRT"],
					returnData["VERTEX_UPDT_DATE"]== System.DBNull.Value ? DateTime.MinValue: (DateTime ) returnData["VERTEX_UPDT_DATE"],
					returnData["VERTEX_UPDT_NUM"]== System.DBNull.Value ? string.Empty: (String ) returnData["VERTEX_UPDT_NUM"],
					returnData["VERTEX_EFF_DATE"]== System.DBNull.Value ? string.Empty: (String ) returnData["VERTEX_EFF_DATE"],
					returnData["STAX_P_A"]== System.DBNull.Value ? string.Empty: (String ) returnData["STAX_P_A"],
					returnData["ACCR_S_A"]== System.DBNull.Value ? string.Empty: (String ) returnData["ACCR_S_A"],
					returnData["CITY_STS"]== System.DBNull.Value ? string.Empty: (String ) returnData["CITY_STS"],
					returnData["AR5_UNUSED_1"]== System.DBNull.Value ? string.Empty: (String ) returnData["AR5_UNUSED_1"],
					returnData["ZIP_STS"]== System.DBNull.Value ? string.Empty: (String ) returnData["ZIP_STS"],
					returnData["STATE_STS"]== System.DBNull.Value ? string.Empty: (String ) returnData["STATE_STS"],
					returnData["COUNTY_STS"]== System.DBNull.Value ? string.Empty: (String ) returnData["COUNTY_STS"],
					returnData["AR5_UNUSED_2"]== System.DBNull.Value ? string.Empty: (String ) returnData["AR5_UNUSED_2"],
					returnData["COUNTY_CODE_STS"]== System.DBNull.Value ? string.Empty: (String ) returnData["COUNTY_CODE_STS"],
					returnData["TF_STATE"]== System.DBNull.Value ? string.Empty: (String ) returnData["TF_STATE"],
					returnData["TF_COUNTY"]== System.DBNull.Value ? string.Empty: (String ) returnData["TF_COUNTY"],
					returnData["TF_CITY"]== System.DBNull.Value ? string.Empty: (String ) returnData["TF_CITY"],
					returnData["STATE_DESC"]== System.DBNull.Value ? string.Empty: (String ) returnData["STATE_DESC"],
					returnData["NO_OVRDE_T_C"]== System.DBNull.Value ? string.Empty: (String ) returnData["NO_OVRDE_T_C"],
					returnData["TOTAL_TAX"]== System.DBNull.Value ? string.Empty: (String ) returnData["TOTAL_TAX"],
					returnData["AR5_UNUSED_3"]== System.DBNull.Value ? string.Empty: (String ) returnData["AR5_UNUSED_3"],
					returnData["STAX_RATE"]== System.DBNull.Value ? 0: (Double ) returnData["STAX_RATE"],
					returnData["MAX_STAX"]== System.DBNull.Value ? 0: (Double ) returnData["MAX_STAX"],
					returnData["COUNTY_TAX_IF_OTHER"]== System.DBNull.Value ? 0: (Double ) returnData["COUNTY_TAX_IF_OTHER"],
					returnData["STATE_TAX_IF_OTHER"]== System.DBNull.Value ? 0: (Double ) returnData["STATE_TAX_IF_OTHER"],
					returnData["ST_STAX_RATE"]== System.DBNull.Value ? 0: (Double ) returnData["ST_STAX_RATE"],
					returnData["CNTY_STAX_RATE"]== System.DBNull.Value ? 0: (Double ) returnData["CNTY_STAX_RATE"],
					returnData["MAX_OTHER"]== System.DBNull.Value ? 0: (Double ) returnData["MAX_OTHER"],
					returnData["TAX_RATE_TOTAL"]== System.DBNull.Value ? 0: (Double ) returnData["TAX_RATE_TOTAL"],
					returnData["USE_CANADA"]== System.DBNull.Value ? string.Empty: (String ) returnData["USE_CANADA"],
					returnData["TAX_TAX"]== System.DBNull.Value ? string.Empty: (String ) returnData["TAX_TAX"],
					returnData["TAX_SPL_CHG"]== System.DBNull.Value ? string.Empty: (String ) returnData["TAX_SPL_CHG"]

				);
				//adding the Employee to the collection
				colTblTax.Add(newTblTax);
			}
			
			//returns the collection of Companys 
			return (colTblTax);
		}
		
		#endregion
		#region Constants and Default Values
		
		public static Int32 GetTaxIdMinValue
		{
			get
			{
				return 0;
			}
		}
		
		//create method related contants
			internal const string SPR_TBLTAX_CREATENEWTBLTAX="spr_TblTax_CreateNewTblTax";
			internal const string SPR_TBLTAX_UPDATETBLTAX="spr_TblTax_UpdateTblTax";
			internal const string SPR_TBLTAX_DELETETBLTAX="spr_TblTax_DeleteTblTax";
			internal const string SPR_TBLTAX_DELETETBLTAXLIST="spr_TblTax_DeleteTblTaxList";
			internal const string SPR_TBLTAX_GETTBLTAXBYTAXID="spr_TblTax_GetTblTaxByTaxId";
			internal const string SPR_TBLTAX_GETALLTBLTAX="spr_TblTax_GetAllTblTax";
			internal const string SPR_TBLTAX_GETALLTBLTAXPAGED="spr_TblTax_GetAllTblTaxPaged";
			internal const string SPR_TBLTAX_GETALLTBLTAXPAGEDCOUNT="spr_TblTax_GetAllTblTaxPagedCount";
		
		#endregion
	}
}	
